/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hyce;

import java.io.FileOutputStream;

/**
 *
 * @author goodsam
 */
public class Output
{
    private FileOutputStream writer;
    private String filename;

    public FileOutputStream getWriter()
    {
        return this.writer;
    }

    public void setFileName(String name)
    {
        this.filename = name;
    }

    public void createWriter() throws Exception
    {
        this.writer = new FileOutputStream(this.filename);
    }

    public void writeToFile(byte[] toWrite) throws Exception
    {
        if (this.filename == null)
            this.filename = "EncryptedImage.des";
        if (this.writer == null)
            this.writer = new FileOutputStream(filename);

        this.writer.write(toWrite);
    }

    public void closeWriter() throws Exception
    {
        if (this.writer != null)
            this.writer.close();
    }
}
